package com.bob.light.activity.delegate

import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
import com.bob.light.TuyaHomeSDKHelper
import com.bob.light.toast
import com.tuya.smart.home.sdk.api.ITuyaHomeChangeListener
import com.tuya.smart.sdk.bean.DeviceBean
import com.tuya.smart.sdk.bean.GroupBean

class FamilyManagerDelegate : LifecycleObserver, ITuyaHomeChangeListener {

    @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
    fun onCreate() {
        TuyaHomeSDKHelper.registerTuyaHomeChangeListener(this)
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
    fun onDestroy() {
        TuyaHomeSDKHelper.unRegisterTuyaHomeChangeListener(this)
    }

    override fun onHomeInfoChanged(homeId: Long) {
        "ID:${homeId}-家庭信息变更".toast()
    }

    override fun onSharedGroupList(sharedGroupList: MutableList<GroupBean>?) {
        "分享群组列表变更".toast()
    }

    override fun onHomeRemoved(homeId: Long) {
        "ID:${homeId}-家庭删除成功".toast()
    }

    override fun onHomeInvite(homeId: Long, homeName: String?) {
        "${homeName}家庭邀请".toast()
    }

    override fun onSharedDeviceList(sharedDeviceList: MutableList<DeviceBean>?) {
        "分享设备列表变更".toast()
    }

    override fun onServerConnectSuccess() {
        "手机连接涂鸦云服务器成功".toast()
    }

    override fun onHomeAdded(homeId: Long) {
        "ID:${homeId}-家庭添加成功".toast()
    }


}